<template>
  <div class='goodList'>
    <div class='goodItem'
         v-for='item in goodList'
         :key='item.id'
         @click='toGoodDetail(item.id)'
    >
      <img :src='item.primaryPicUrl' alt=''>
      <div class='goodDescription'>{{ item.name }}</div>
      <div class='goodPrice'>￥<span>{{ item.retailPrice }}</span></div>
      <div class='activity'>只要九块九哈哈哈哈哈</div>
    </div>
  </div>
</template>

<script setup lang='ts'>
import type { GoodItem } from '@/types/search.d.ts'
import { useRouter } from 'vue-router'

defineProps<{
  goodList: GoodItem[]
}>()
const router = useRouter()
const toGoodDetail = (id: number) => {
  router.push(`/detail?id=${id}`)
}
</script>
<script lang='ts'>
export default {
  name: 'MyGoodList'
}
</script>

<style scoped lang='less'>
.goodList {
  box-sizing: border-box;
  display: flex;
  flex-wrap: wrap;
}

.goodItem {
  box-sizing: border-box;
  width: 187.5px;
  height: 302.5px;
  padding: 5px;
  background-color: #fff;
  border: 1px solid #eee;

  img {
    width: 172.5px;
    height: 172.5px;
    border-radius: 0.16rem
  }

  .goodDescription {
    width: 172.5px;
    height: 40px;
    font-size: 14px;
  }

  .goodPrice {
    width: 172.5px;
    height: 30px;
    color: rgb(250, 30, 50);
    font-size: 0.2rem;
    font-weight: 700;
    span {
      font-size: 20px;
    }
  }

  .activity {
    width: 172.5px;
    height: 23px;
    margin: 5px 0 0;
    font-size: 13px;
  }
}
</style>
